<?php 
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../DAO/CountriesDAO.php';
class CountriesService
{
	public function create(BaseContext $context, ServiceResult $result, CountriesDomain $countriesDomain)
	{
		try
		{
			$countriesDAO = new CountriesDAO($context);
			$countriesDAO->create($countriesDomain);
			$result->setSuccess();
		}
		catch (Exception $e)
		{
			$context->logException($e);
			$result->setException($e);
		}
	}

	public function update(BaseContext $context, ServiceResult $result, CountriesDomain $countriesDomain)
	{
		try
		{
			$countriesDAO = new CountriesDAO($context);
			$countriesDAO->update($countriesDomain);
			$result->setSuccess();
		}
		catch (Exception $e)
		{
			$context->logException($e);
			$result->setException($e);
		}
	}

	public function delete(BaseContext $context, ServiceResult $result, $oid)
	{
		try
		{
			$countriesDAO = new CountriesDAO($context);
			$countriesDAO->delete($oid);
			$result->setSuccess();
		}
		catch (Exception $e)
		{
			$context->logException($e);
			$result->setException($e);
		}
	}

	public function findByOid(BaseContext $context, ServiceResult $result, $oid)
	{
		try
		{
			$countriesDAO = new CountriesDAO($context);
			$countriesDomain = $countriesDAO->findByOid($oid);
			$result->setSuccess();
			return $countriesDomain;
		}
		catch (Exception $e)
		{
			$context->logException($e);
			$result->setException($e);
		}
	}

	public function findAll(BaseContext $context, ServiceResult $result)
	{
		try
		{
			$countriesDAO = new CountriesDAO($context);
			$countriesDomainArr = $countriesDAO->findAll();
			$result->setSuccess();
			return $countriesDomainArr;
		}
		catch (Exception $e)
		{
			$context->logException($e);
			$result->setException($e);
		}
	}

}
?>